﻿@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Localization
@inject IViewLocalizer Localizer
@inject IStringLocalizer<SharedResource> SharedLocalizer
@{
    ViewBag.Title = "";
}
@section styles{
    <style>
        .table > tbody > tr > td {
            vertical-align: middle;
        }
    </style>
}
<div class="container">
    <div class="form-inline" style="margin: 1em 0">
        <div class="form-group">
            <input type="search" name="SearchItem1" id="contactPhone" value="" placeholder="@Localizer["ReservationPhoneNumber"]" class="form-control" />
        </div>
        <button id="btnSearch" type="button" class="btn btn-primary">@SharedLocalizer["Search"]</button> <br />
    </div>
    <div id="div_main">
    </div>
    <form id="checkForm" class="hidden" action="@Url.Action("Check")" method="post">
        <input name="id" id="reId" value="" />
        <input name="phone" id="rePhone" />
    </form>
</div>
@section scripts{
    <script>
        var pageSize = 10;

        function loadData(pageIndex) {
            $("#div_main").html('<br /><img src="/images/loading.gif" /> @(SharedLocalizer["LoadingTip"])');
            if (!pageIndex) {
                pageIndex = 1;
            }
            $.get("/Home/ReservationList",
                { "PageIndex": pageIndex, "PageSize": pageSize, "SearchItem1": $("#contactPhone").val() },
                function (data, status) {
                    if (status == "success") {
                        $("#div_main").html(data);
                    } else {
                        $("#div_main").html('');
                        layer.msg('@(SharedLocalizer["LoadDataException"])');
                    }
                });
        }

        function view(id) {
            $("#rePhone").val('');
            $("#reId").val(id);
            layer.prompt({
                title: '@Localizer["PhoneNumberInputPrompt"]',
                formType: 0 //prompt style
            },
                function (param) {
                    if (param) {
                        $("#rePhone").val(param);
                        $("#checkForm").submit();
                    }
                    return false;
                });
        }

        //search
        $("#btnSearch").on("click",
            function () {
                loadData();
            });
        $(function () {
            loadData();
        });
    </script>
}